/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package app.entity;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Deviant
 */
@Entity
@Table(name = "UserInformation", catalog = "mysweethome", schema = "dbo")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "UserInformation.findAll", query = "SELECT u FROM UserInformation u"),
    @NamedQuery(name = "UserInformation.findByUsername", query = "SELECT u FROM UserInformation u WHERE u.username = :username"),
    @NamedQuery(name = "UserInformation.findByFullname", query = "SELECT u FROM UserInformation u WHERE u.fullname = :fullname"),
    @NamedQuery(name = "UserInformation.findByGender", query = "SELECT u FROM UserInformation u WHERE u.gender = :gender"),
    @NamedQuery(name = "UserInformation.findByAddress", query = "SELECT u FROM UserInformation u WHERE u.address = :address"),
    @NamedQuery(name = "UserInformation.findByEmail", query = "SELECT u FROM UserInformation u WHERE u.email = :email"),
    @NamedQuery(name = "UserInformation.findByPhone", query = "SELECT u FROM UserInformation u WHERE u.phone = :phone"),
    @NamedQuery(name = "UserInformation.findByBirthday", query = "SELECT u FROM UserInformation u WHERE u.birthday = :birthday"),
    @NamedQuery(name = "UserInformation.findByAvatar", query = "SELECT u FROM UserInformation u WHERE u.avatar = :avatar")})
public class UserInformation implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 50)
    @Column(name = "username", nullable = false, length = 50)
    private String username;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 50)
    @Column(name = "fullname", nullable = false, length = 50)
    private String fullname;
    @Basic(optional = false)
    @NotNull
    @Column(name = "gender", nullable = false)
    private boolean gender;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 50)
    @Column(name = "address", nullable = false, length = 50)
    private String address;
    // @Pattern(regexp="[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?", message="Invalid email")//if the field contains email address consider using this annotation to enforce field validation
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 50)
    @Column(name = "email", nullable = false, length = 50)
    private String email;
    // @Pattern(regexp="^\\(?(\\d{3})\\)?[- ]?(\\d{3})[- ]?(\\d{4})$", message="Invalid phone/fax format, should be as xxx-xxx-xxxx")//if the field contains phone or fax number consider using this annotation to enforce field validation
    @Size(max = 20)
    @Column(name = "phone", length = 20)
    private String phone;
    @Basic(optional = false)
    @NotNull
    @Column(name = "birthday", nullable = false)
    @Temporal(TemporalType.TIMESTAMP)
    private Date birthday;
    @Size(max = 50)
    @Column(name = "avatar", length = 50)
    private String avatar;
    @JoinColumn(name = "username", referencedColumnName = "username", nullable = false, insertable = false, updatable = false)
    @OneToOne(optional = false)
    private Account account;

    public UserInformation() {
    }

    public UserInformation(String username) {
        this.username = username;
    }

    public UserInformation(String username, String fullname, boolean gender, String address, String email, Date birthday) {
        this.username = username;
        this.fullname = fullname;
        this.gender = gender;
        this.address = address;
        this.email = email;
        this.birthday = birthday;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getFullname() {
        return fullname;
    }

    public void setFullname(String fullname) {
        this.fullname = fullname;
    }

    public boolean getGender() {
        return gender;
    }

    public void setGender(boolean gender) {
        this.gender = gender;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public Date getBirthday() {
        return birthday;
    }

    public void setBirthday(Date birthday) {
        this.birthday = birthday;
    }

    public String getAvatar() {
        return avatar;
    }

    public void setAvatar(String avatar) {
        this.avatar = avatar;
    }

    public Account getAccount() {
        return account;
    }

    public void setAccount(Account account) {
        this.account = account;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (username != null ? username.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof UserInformation)) {
            return false;
        }
        UserInformation other = (UserInformation) object;
        if ((this.username == null && other.username != null) || (this.username != null && !this.username.equals(other.username))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "app.entity.UserInformation[ username=" + username + " ]";
    }
    
}
